{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取excel文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "excel_file = r'/home/excel/python_program/data/lab1/SH#600519.xlsx'\n",
    "\n",
    "data = pd.read_excel(excel_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/home/excel/python_program/data/lab1/SH#600519.xlsx'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "excel_file"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 新建一个 DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "df = pd.DataFrame(data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 获取dataframe的列标题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "head = df.columns.values.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['600519 贵州茅台 日线 前复权',\n",
       " 'Unnamed: 1',\n",
       " 'Unnamed: 2',\n",
       " 'Unnamed: 3',\n",
       " 'Unnamed: 4',\n",
       " 'Unnamed: 5',\n",
       " 'Unnamed: 6']"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "原列名\n",
    "'''\n",
    "head"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "'''\n",
    "修改列名：\n",
    "    df.rename(columns={'原列名'：'新列名'},inplace=True)\n",
    "'''\n",
    "for i in range (len(head)):\n",
    "    df.rename(columns={head[i]:df.iloc[0,i]},inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['      日期', '    开盘', '    最高', '    最低', '    收盘', '    成交量', '    成交额']"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "修改后的列名\n",
    "'''\n",
    "head=df.columns.values.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "'''\n",
    "修改后的列名\n",
    "'''\n",
    "head=df.columns.values.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.drop(0,axis=0,inplace=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1237</th>\n",
       "      <td>2007-01-15 00:00:00</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>0.27</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>-1.51</td>\n",
       "      <td>3067052</td>\n",
       "      <td>305993920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1239</th>\n",
       "      <td>2007-01-17 00:00:00</td>\n",
       "      <td>-3.03</td>\n",
       "      <td>1.02</td>\n",
       "      <td>-4.21</td>\n",
       "      <td>-2.63</td>\n",
       "      <td>2591604</td>\n",
       "      <td>257353984</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1240</th>\n",
       "      <td>2007-01-18 00:00:00</td>\n",
       "      <td>-2.72</td>\n",
       "      <td>2.89</td>\n",
       "      <td>-3.47</td>\n",
       "      <td>2.69</td>\n",
       "      <td>3064535</td>\n",
       "      <td>315103136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1241</th>\n",
       "      <td>2007-01-19 00:00:00</td>\n",
       "      <td>2.69</td>\n",
       "      <td>7.7</td>\n",
       "      <td>2.69</td>\n",
       "      <td>5.79</td>\n",
       "      <td>2225551</td>\n",
       "      <td>243504208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1242</th>\n",
       "      <td>2007-01-22 00:00:00</td>\n",
       "      <td>6.36</td>\n",
       "      <td>10.79</td>\n",
       "      <td>6.28</td>\n",
       "      <td>8.69</td>\n",
       "      <td>2552122</td>\n",
       "      <td>290839232</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期     开盘     最高     最低     收盘      成交量        成交额\n",
       "1237  2007-01-15 00:00:00  -3.44   0.27  -3.44  -1.51  3067052  305993920\n",
       "1239  2007-01-17 00:00:00  -3.03   1.02  -4.21  -2.63  2591604  257353984\n",
       "1240  2007-01-18 00:00:00  -2.72   2.89  -3.47   2.69  3064535  315103136\n",
       "1241  2007-01-19 00:00:00   2.69    7.7   2.69   5.79  2225551  243504208\n",
       "1242  2007-01-22 00:00:00   6.36  10.79   6.28   8.69  2552122  290839232"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[(df[head[2]]>0),[head[0],head[1],head[2],head[3],head[4],head[5],head[6]]].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1237</th>\n",
       "      <td>2007-01-15 00:00:00</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>0.27</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>-1.51</td>\n",
       "      <td>3067052</td>\n",
       "      <td>305993920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1239</th>\n",
       "      <td>2007-01-17 00:00:00</td>\n",
       "      <td>-3.03</td>\n",
       "      <td>1.02</td>\n",
       "      <td>-4.21</td>\n",
       "      <td>-2.63</td>\n",
       "      <td>2591604</td>\n",
       "      <td>257353984</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1240</th>\n",
       "      <td>2007-01-18 00:00:00</td>\n",
       "      <td>-2.72</td>\n",
       "      <td>2.89</td>\n",
       "      <td>-3.47</td>\n",
       "      <td>2.69</td>\n",
       "      <td>3064535</td>\n",
       "      <td>315103136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1241</th>\n",
       "      <td>2007-01-19 00:00:00</td>\n",
       "      <td>2.69</td>\n",
       "      <td>7.7</td>\n",
       "      <td>2.69</td>\n",
       "      <td>5.79</td>\n",
       "      <td>2225551</td>\n",
       "      <td>243504208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1242</th>\n",
       "      <td>2007-01-22 00:00:00</td>\n",
       "      <td>6.36</td>\n",
       "      <td>10.79</td>\n",
       "      <td>6.28</td>\n",
       "      <td>8.69</td>\n",
       "      <td>2552122</td>\n",
       "      <td>290839232</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期     开盘     最高     最低     收盘      成交量        成交额\n",
       "1237  2007-01-15 00:00:00  -3.44   0.27  -3.44  -1.51  3067052  305993920\n",
       "1239  2007-01-17 00:00:00  -3.03   1.02  -4.21  -2.63  2591604  257353984\n",
       "1240  2007-01-18 00:00:00  -2.72   2.89  -3.47   2.69  3064535  315103136\n",
       "1241  2007-01-19 00:00:00   2.69    7.7   2.69   5.79  2225551  243504208\n",
       "1242  2007-01-22 00:00:00   6.36  10.79   6.28   8.69  2552122  290839232"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "excel_file = r'/home/excel/python_program/data/SH#600519.xlsx'\n",
    "\n",
    "data = pd.read_excel(excel_file)\n",
    "\n",
    "df = pd.DataFrame(data)\n",
    "\n",
    "'''\n",
    "原列名\n",
    "'''\n",
    "head = df.columns.values.tolist()\n",
    "\n",
    "'''\n",
    "修改列名：\n",
    "    df.rename(columns={'原列名'：'新列名'},inplace=True)\n",
    "'''\n",
    "for i in range (len(head)):\n",
    "    df.rename(columns={head[i]:df.iloc[0,i]},inplace=True)\n",
    "\n",
    "'''\n",
    "修改后的列名\n",
    "'''\n",
    "head=df.columns.values.tolist()\n",
    "\n",
    "'''\n",
    "删除第一行\n",
    "'''\n",
    "df = df.drop(0,axis=0,inplace=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### i. 输入日期"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2007-01-16 00:00:00\n"
     ]
    }
   ],
   "source": [
    "date = input()\n",
    "dates = pd.to_datetime(date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1238</th>\n",
       "      <td>2007-01-16 00:00:00</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>-0.63</td>\n",
       "      <td>-4.01</td>\n",
       "      <td>-2.93</td>\n",
       "      <td>3503970</td>\n",
       "      <td>344077696</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期     开盘     最高     最低     收盘      成交量        成交额\n",
       "1238  2007-01-16 00:00:00   -1.7  -0.63  -4.01  -2.93  3503970  344077696"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[\n",
    "    (df[head[0]]==dates),\n",
    "     [head[0],head[1],head[2],\n",
    "      head[3],head[4],head[5],\n",
    "      head[6]\n",
    "     ]\n",
    "    ].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### ii. 收盘价"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "flag=(int)(input())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1240</th>\n",
       "      <td>2007-01-18 00:00:00</td>\n",
       "      <td>-2.72</td>\n",
       "      <td>2.89</td>\n",
       "      <td>-3.47</td>\n",
       "      <td>2.69</td>\n",
       "      <td>3064535</td>\n",
       "      <td>315103136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1241</th>\n",
       "      <td>2007-01-19 00:00:00</td>\n",
       "      <td>2.69</td>\n",
       "      <td>7.7</td>\n",
       "      <td>2.69</td>\n",
       "      <td>5.79</td>\n",
       "      <td>2225551</td>\n",
       "      <td>243504208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1242</th>\n",
       "      <td>2007-01-22 00:00:00</td>\n",
       "      <td>6.36</td>\n",
       "      <td>10.79</td>\n",
       "      <td>6.28</td>\n",
       "      <td>8.69</td>\n",
       "      <td>2552122</td>\n",
       "      <td>290839232</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1243</th>\n",
       "      <td>2007-01-23 00:00:00</td>\n",
       "      <td>9.14</td>\n",
       "      <td>9.89</td>\n",
       "      <td>1.85</td>\n",
       "      <td>2.74</td>\n",
       "      <td>4178280</td>\n",
       "      <td>450098208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1244</th>\n",
       "      <td>2007-01-24 00:00:00</td>\n",
       "      <td>2.9</td>\n",
       "      <td>8.54</td>\n",
       "      <td>2.9</td>\n",
       "      <td>6.12</td>\n",
       "      <td>1940422</td>\n",
       "      <td>212553648</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期     开盘     最高     最低     收盘      成交量        成交额\n",
       "1240  2007-01-18 00:00:00  -2.72   2.89  -3.47   2.69  3064535  315103136\n",
       "1241  2007-01-19 00:00:00   2.69    7.7   2.69   5.79  2225551  243504208\n",
       "1242  2007-01-22 00:00:00   6.36  10.79   6.28   8.69  2552122  290839232\n",
       "1243  2007-01-23 00:00:00   9.14   9.89   1.85   2.74  4178280  450098208\n",
       "1244  2007-01-24 00:00:00    2.9   8.54    2.9   6.12  1940422  212553648"
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[\n",
    "        (df[head[4]]>flag),\n",
    "       [head[0],head[1],head[2],\n",
    "        head[3],head[4],head[5],\n",
    "        head[6]\n",
    "       ]\n",
    "      ].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### iii. 波动"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.1\n"
     ]
    }
   ],
   "source": [
    "wave = (float)(input())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2001-08-27 00:00:00</td>\n",
       "      <td>-70.43</td>\n",
       "      <td>-69.78</td>\n",
       "      <td>-70.76</td>\n",
       "      <td>-70.23</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1410347136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-08-28 00:00:00</td>\n",
       "      <td>-70.34</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.41</td>\n",
       "      <td>-69.96</td>\n",
       "      <td>12964700</td>\n",
       "      <td>463463136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2001-08-29 00:00:00</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.12</td>\n",
       "      <td>-70.06</td>\n",
       "      <td>5325200</td>\n",
       "      <td>194689616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2001-08-30 00:00:00</td>\n",
       "      <td>-70.08</td>\n",
       "      <td>-69.84</td>\n",
       "      <td>-70.14</td>\n",
       "      <td>-69.92</td>\n",
       "      <td>4801300</td>\n",
       "      <td>177558560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2001-08-31 00:00:00</td>\n",
       "      <td>-69.91</td>\n",
       "      <td>-69.81</td>\n",
       "      <td>-69.98</td>\n",
       "      <td>-69.93</td>\n",
       "      <td>2323100</td>\n",
       "      <td>86231000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    日期     开盘     最高     最低     收盘       成交量         成交额\n",
       "1  2001-08-27 00:00:00 -70.43 -69.78 -70.76 -70.23  40631800  1410347136\n",
       "2  2001-08-28 00:00:00 -70.34 -69.94 -70.41 -69.96  12964700   463463136\n",
       "3  2001-08-29 00:00:00 -69.94 -69.94 -70.12 -70.06   5325200   194689616\n",
       "4  2001-08-30 00:00:00 -70.08 -69.84 -70.14 -69.92   4801300   177558560\n",
       "5  2001-08-31 00:00:00 -69.91 -69.81 -69.98 -69.93   2323100    86231000"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[ \n",
    "      ( df[head[2]] > (wave+df[head[3]]) ),\n",
    "        [head[0],head[1],head[2],\n",
    "         head[3],head[4],head[5],\n",
    "         head[6]]\n",
    "      ].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### iv. 成交量高于输入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "900000\n"
     ]
    }
   ],
   "source": [
    "turnover = (int)(input())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2001-08-27 00:00:00</td>\n",
       "      <td>-70.43</td>\n",
       "      <td>-69.78</td>\n",
       "      <td>-70.76</td>\n",
       "      <td>-70.23</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1410347136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-08-28 00:00:00</td>\n",
       "      <td>-70.34</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.41</td>\n",
       "      <td>-69.96</td>\n",
       "      <td>12964700</td>\n",
       "      <td>463463136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2001-08-29 00:00:00</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.12</td>\n",
       "      <td>-70.06</td>\n",
       "      <td>5325200</td>\n",
       "      <td>194689616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2001-08-30 00:00:00</td>\n",
       "      <td>-70.08</td>\n",
       "      <td>-69.84</td>\n",
       "      <td>-70.14</td>\n",
       "      <td>-69.92</td>\n",
       "      <td>4801300</td>\n",
       "      <td>177558560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2001-08-31 00:00:00</td>\n",
       "      <td>-69.91</td>\n",
       "      <td>-69.81</td>\n",
       "      <td>-69.98</td>\n",
       "      <td>-69.93</td>\n",
       "      <td>2323100</td>\n",
       "      <td>86231000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    日期     开盘     最高     最低     收盘       成交量         成交额\n",
       "1  2001-08-27 00:00:00 -70.43 -69.78 -70.76 -70.23  40631800  1410347136\n",
       "2  2001-08-28 00:00:00 -70.34 -69.94 -70.41 -69.96  12964700   463463136\n",
       "3  2001-08-29 00:00:00 -69.94 -69.94 -70.12 -70.06   5325200   194689616\n",
       "4  2001-08-30 00:00:00 -70.08 -69.84 -70.14 -69.92   4801300   177558560\n",
       "5  2001-08-31 00:00:00 -69.91 -69.81 -69.98 -69.93   2323100    86231000"
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[\n",
    "      (df[head[5]]>turnover),\n",
    "       [head[0],head[1],head[2],\n",
    "        head[3],head[4],head[5],\n",
    "        head[6]]\n",
    "      ].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### v. 成交额"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9026819\n"
     ]
    }
   ],
   "source": [
    "sums = (int)(input())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2001-08-27 00:00:00</td>\n",
       "      <td>-70.43</td>\n",
       "      <td>-69.78</td>\n",
       "      <td>-70.76</td>\n",
       "      <td>-70.23</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1410347136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-08-28 00:00:00</td>\n",
       "      <td>-70.34</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.41</td>\n",
       "      <td>-69.96</td>\n",
       "      <td>12964700</td>\n",
       "      <td>463463136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2001-08-29 00:00:00</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.12</td>\n",
       "      <td>-70.06</td>\n",
       "      <td>5325200</td>\n",
       "      <td>194689616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2001-08-30 00:00:00</td>\n",
       "      <td>-70.08</td>\n",
       "      <td>-69.84</td>\n",
       "      <td>-70.14</td>\n",
       "      <td>-69.92</td>\n",
       "      <td>4801300</td>\n",
       "      <td>177558560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2001-08-31 00:00:00</td>\n",
       "      <td>-69.91</td>\n",
       "      <td>-69.81</td>\n",
       "      <td>-69.98</td>\n",
       "      <td>-69.93</td>\n",
       "      <td>2323100</td>\n",
       "      <td>86231000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    日期     开盘     最高     最低     收盘       成交量         成交额\n",
       "1  2001-08-27 00:00:00 -70.43 -69.78 -70.76 -70.23  40631800  1410347136\n",
       "2  2001-08-28 00:00:00 -70.34 -69.94 -70.41 -69.96  12964700   463463136\n",
       "3  2001-08-29 00:00:00 -69.94 -69.94 -70.12 -70.06   5325200   194689616\n",
       "4  2001-08-30 00:00:00 -70.08 -69.84 -70.14 -69.92   4801300   177558560\n",
       "5  2001-08-31 00:00:00 -69.91 -69.81 -69.98 -69.93   2323100    86231000"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[(df[head[6]]>sums),\n",
    "       [head[0],head[1],head[2],\n",
    "        head[3],head[4],head[5],head[6]]\n",
    "      ].head()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
